<template>
  <div class="person">
    <h1>情况一:见识[ref]定义的[基本类型]数据</h1>
    <h2>当前求和为:{{ sum }}</h2>
    <button @click="changeSum">修改sum</button>
  </div>
</template>

<script lang="ts" setup>
import {reactive, ref, watch} from "vue";

let sum = ref(0);


function changeSum() {
  sum.value += 1;
  console.log(sum)
  console.log(sum)
}

//监视
const stopWatch = watch(sum, (newValue, oldValue) => {
  console.log('sum变化了', newValue, oldValue)
  if(newValue>10){
    stopWatch()
  }
});
</script>

<style scoped>
.person {
  background-color: #ddd;
  box-shadow: 0 0 10px;
  border-radius: 10px;
  padding: 20px;
}

li {
  font-size: 20px;
}

button {
  margin: 0 10px auto;
}
</style>
